package com.huawei.appgallery.forum.option.comment.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import huawei.widget.HwEditText;
import o.bqx;
import o.btg;

public class EditTextWithListView extends HwEditText {
    private btg ʻ = null;
    private float ˊ;
    private int ˋ;
    private boolean ˎ = false;
    private boolean ˏ = false;
    private boolean ॱ = false;
    private boolean ᐝ = false;

    public EditTextWithListView(Context context) {
        super(context);
    }

    public EditTextWithListView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }

    public EditTextWithListView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
    }

    protected void onMeasure(int i, int i2) {
        super.onMeasure(i, i2);
        this.ˎ = ˊ();
    }

    public boolean dispatchTouchEvent(MotionEvent motionEvent) {
        if (motionEvent.getAction() == 0) {
            this.ॱ = false;
        }
        ˏ(motionEvent);
        if (this.ॱ) {
            motionEvent.setAction(3);
        }
        return super.dispatchTouchEvent(motionEvent);
    }

    public boolean onTouchEvent(MotionEvent motionEvent) {
        boolean onTouchEvent = super.onTouchEvent(motionEvent);
        if (!this.ˎ) {
            getParent().requestDisallowInterceptTouchEvent(false);
        } else if ((getScrollY() == 0 && this.ᐝ) || (getScrollY() == this.ˋ && this.ˏ)) {
            getParent().requestDisallowInterceptTouchEvent(false);
        } else if (!this.ॱ) {
            getParent().requestDisallowInterceptTouchEvent(true);
        }
        return onTouchEvent;
    }

    protected void onScrollChanged(int i, int i2, int i3, int i4) {
        super.onScrollChanged(i, i2, i3, i4);
        if (i2 == this.ˋ || i2 == 0) {
            getParent().requestDisallowInterceptTouchEvent(false);
            this.ॱ = true;
        }
    }

    private boolean ˊ() {
        int measuredHeight;
        int scrollY = getScrollY();
        int height = getLayout().getHeight();
        if (getHeight() == 0) {
            measuredHeight = getMeasuredHeight();
        } else {
            measuredHeight = (getHeight() - getCompoundPaddingTop()) - getCompoundPaddingBottom();
        }
        this.ˋ = height - measuredHeight;
        if (this.ˋ == 0) {
            return false;
        }
        boolean z = scrollY > 0 || scrollY < this.ˋ - 1;
        return z;
    }

    private void ˏ(MotionEvent motionEvent) {
        if (motionEvent.getAction() == 0) {
            this.ˏ = false;
            this.ᐝ = false;
            this.ˊ = motionEvent.getY();
        } else if (2 == motionEvent.getAction()) {
            float y = motionEvent.getY() - this.ˊ;
            if (y > 0.0f) {
                this.ᐝ = true;
            }
            if (y < 0.0f) {
                this.ˏ = true;
            }
        } else {
            bqx.ˊ("EditTextWithListView", "invalid motionevent");
        }
    }

    protected void onSelectionChanged(int i, int i2) {
        super.onSelectionChanged(i, i2);
        if (this.ʻ != null) {
            this.ʻ.ˊ(this, i, i2);
        }
    }

    public void setSelectionChangedListener(btg o_btg) {
        this.ʻ = o_btg;
    }
}
